package com.exam.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.exam.domain.DTO.ExamingDTO;
import com.exam.handler.StpHandler;
import com.exam.service.ExamTeacherService;
import com.exam.service.MarkService;
import com.exam.utils.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "批阅管理")
@RestController
@RequestMapping(value = "/mark")
public class MarkController {

    @Autowired
    private ExamTeacherService examTeacherService;

    @Autowired
    private MarkService markService;

    @GetMapping("/getAnswerSheet")
    @ApiOperation(value = "获取某学生答题卡批阅信息", notes = "获取某学生答题批阅信息卡")
    @SaCheckPermission("teacher")
    public ResultBody getAnswerSheetWithAnswer(@RequestParam int examId, @RequestParam String studentId) {
        return ResultBody.success(examTeacherService.getAnswerSheetWithAnswer(examId, studentId));
    }

    @PostMapping("/postAnswerSheet")
    @ApiOperation(value = "上传批阅的信息", notes = "上传批阅的信息")
    @SaCheckPermission("teacher")
    public ResultBody postAnswerSheetWithAnswer(@RequestParam int examId, @RequestParam String studentId, @RequestBody List<ExamingDTO> examingDTOList) {
        return ResultBody.success(examTeacherService.markExamInfo(examId, studentId, examingDTOList));
    }

//    @ApiOperation("根据答题卡id自动批阅客观题（单选、多选、填空、判断）")
//    @GetMapping("/markObjective/{answerSheetId}")
//    public ResultBody markObjectiveByAnswerSheet(@PathVariable int answerSheetId) {
//        return ResultBody.success(markService.markObjectiveByAnswerSheet(answerSheetId));
//    }

//    @ApiOperation("根据回答id和分数更新主观题得分")
//    @GetMapping("/markSubjective")
//    public ResultBody markSubjectiveByAnswer(@RequestParam int answerId, @RequestParam double score) {
//        return ResultBody.success(markService.markSubjectiveById(answerId, score));
//    }

//    @ApiOperation("发布全部答题卡的成绩")
//    @GetMapping("/publishExamGrade/{examId}")
//    public ResultBody publishExamGrade(@PathVariable int examId) {
//        return ResultBody.success(markService.publishAllGrade(examId));
//    }

//    @ApiOperation("单独发布某张答题卡的成绩")
//    @GetMapping("/publishGrade/{answerSheetId}")
//    public ResultBody publishGrade(@PathVariable int answerSheetId) {
//        return ResultBody.success(markService.publishGrade(answerSheetId));
//    }

}
